home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
amusemen
/
nolan-1.1
/
nolan.tar
/
compilescript
next >
Wrap
Text File
|
1994-04-25
|
2KB
|
91 lines
#
# This script generates C code from its input, which is presumed to be in the
# baby script language documented for the purpose. This code then gets
# included in nolan.c to become the actual script program
#
sed <nolan.script \
-e '1,$s/\\[^n]/\\&/g' \
-e '1,$s/"/\\"/g' \
| awk '
BEGIN {nroutines = 0;}
/^@action / {printf(" %s", substr($0, 9)); next;}
/^@before / {
printf(" if (found > 1)\n");
printf(" display(\"%s\\n\");\n", substr($0, 9));
printf(" else\n");
printf(" display(\"\\n\");\n");
next;
}
/^@center / {
text = substr($0, 8);
printf(" movecursor(row, CENTER(\"%s\"));\n", text);
printf(" display(\"%s\\n\");\n", text);
next;
}
/^@diamond/ {
print " down = DOWN(economic, personal);"
print " scatter[personal][economic]++;"
next;
}
/^@dispatch/ {exitready = 2; next;}
/^@endscreen/ {
if (exitready == 0)
printf(" return(screenend(NEXT, %s));\n",$2);
else if (exitready == 1)
print " return(screenend(EXIT, NULL));";
else
print " return(screenend(dispatch(),NULL));";
print "}"
screennum++;
next;
}
/^@exitprompt/ {exitready = 1; next;}
/^@exit\$/ {printf(" return(EXIT);\n"); next;}
/^@scattergram/ {printf(" scattergram();\n"); next;}
/^@screen/ {
printf("\nstatic int %s()\n{\n",$2);
printf(" down=-1; score = nquestions = row = 0;\n");
printf(" clearscreen();\n");
exitready = linecnt = 0;
routines[nroutines++] = $2;
next;
}
/^@standout{/ {
printf("#define STANDOUT \"%s\"\n", substr($0, 11, 1));
next;
}
/^@authoritarian/ {
printf("#define AUT_SCREEN %d\n", screennum);
next;
}
/^@conservative/ {
printf("#define CON_SCREEN %d\n", screennum);
next;
}
/^@centrist/ {
printf("#define CEN_SCREEN %d\n", screennum);
next;
}
/^@left-liberal/ {
printf("#define LEF_SCREEN %d\n", screennum);
next;
}
/^@libertarian/ {
printf("#define LIB_SCREEN %d\n", screennum);
next;
}
{
printf(" display(\"%s\\n\");\n", $0);
}
END {
print "\nstatic intfunc screenfuncs[] = {"
for (i = 0; i < nroutines; i++)
printf(" %s,\n", routines[i]);
print " (intfunc)NULL"
print "};"
}
'